package leetcode.greed;

import java.util.Arrays;

public class Test455 {

    public static void main(String[] args) {
        int[] g = {1,2};
        int[] s = {1,2,3};
        int contentChildren = findContentChildren(g, s);
        System.out.println(contentChildren);
    }

    public static int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int left = 0,right = 0;
        while (left< g.length && right < s.length){
            if (g[left]<=s[right]){
                left++;
                right++;
            }
            else{
                right++;
            }
        }
            return left;
    }
}
